// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import FastClick from 'fastclick';
import VueRouter from 'vue-router';
import { querystring } from 'vux';
import VueLazyload from 'vue-lazyload';
import VConsole from 'vconsole';
import store from 'store';
import App from './App';
import router from './router/index';
import './utils/__fabric';
import { buyItem, pay } from './utils/pay';
import './assets/less/common.less';
import config from './config';

Vue.use(VueRouter);
Vue.use(VueLazyload);

let queryObj = querystring.parse(window.location.search);
if (queryObj.token && !config.token) config.token = queryObj.token;
if (!config.token) {
    window.location.href = `${config.apiHost}/user/mp/auth?appId=${config.appId}&productType=${config.productType}&redirectUri=${config.h5Host}`;
}
Vue.prototype.config = config;
FastClick.attach(document.body);

Vue.prototype.$buy = buyItem;
Vue.config.productionTip = false;

let vconsole = new VConsole();
/* eslint-disable no-new */
new Vue({
    router,
    render: h => h(App)
}).$mount('#app-box');
